package com.bawei.module_goods.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.bawei.module_goods.databinding.ItemMallTabItemBinding
import com.bawei.module_goods.entity.GroupType

class MallTabAdapter : RecyclerView.Adapter<MallTabAdapter.TabViewHolder>() {

    private val tabList = mutableListOf<GroupType>()

    fun submitList(list: List<GroupType>) {
        tabList.clear()
        tabList.addAll(list)
        notifyDataSetChanged()
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TabViewHolder {
        val binding = ItemMallTabItemBinding.inflate(LayoutInflater.from(parent.context), parent, false)
        return TabViewHolder(binding)
    }

    override fun getItemCount(): Int = tabList.size

    override fun onBindViewHolder(holder: TabViewHolder, position: Int) {
        holder.bind(tabList[position])
    }

    class TabViewHolder(private val binding: ItemMallTabItemBinding) : RecyclerView.ViewHolder(binding.root) {
        fun bind(tab: GroupType) {
            binding.tvTabName.text = tab.name
            // 可添加点击事件等
        }
    }
} 